﻿SET QUOTED_IDENTIFIER ON
GO
SET ARITHABORT ON
GO
SET NUMERIC_ROUNDABORT OFF
GO
SET CONCAT_NULL_YIELDS_NULL ON
GO
SET ANSI_NULLS ON
GO
SET ANSI_PADDING ON
GO
SET ANSI_WARNINGS ON
GO


ALTER PROCEDURE [dbo].[bhp_NemoGroupGet]
	@Id				INT
AS
BEGIN

	SELECT
		t.id as [Id],
		g.Name,
		t.name as SystemName,
		g.Identyficator,
		'T' + CAST(t.id as NVARCHAR(10)) as SelectTable,
		CASE t.typ WHEN 'T' THEN 'Table' WHEN 'V' THEN 'View' WHEN 'TE' THEN 'ExtendedTable' ELSE '' END as [Type]
	FROM
		sTree t
		LEFT JOIN bht_Groups g ON t.id = g.Id
	WHERE
		t.del = 0
		AND t.parent = 0
		AND t.id = @Id
END

GO


ALTER PROCEDURE [dbo].[bhp_NemoGroupGetAll]
AS
BEGIN

	SELECT
		t.id as [Id],
		g.Name,
		t.name as SystemName,
		g.Identyficator,
		'T' + CAST(t.id as NVARCHAR(10)) as SelectTable,
		CASE t.typ WHEN 'T' THEN 'Table' WHEN 'V' THEN 'View' WHEN 'TE' THEN 'ExtendedTable' ELSE '' END as [Type]
	FROM
		sTree t
		LEFT JOIN bht_Groups g ON t.id = g.Id
	WHERE
		t.del = 0
		AND t.parent = 0

END

GO
